package com.hancher.gamelife2.diary;

import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.hancher.common.javautil.EmptyUtil;
import com.hancher.common.rv.BaseVBAdapter;
import com.hancher.gamelife2.R;
import com.hancher.gamelife2.databinding.ItemDiarySubPictureBinding;

public class DiaryListSubImageAdapter extends BaseVBAdapter<ItemDiarySubPictureBinding, String> {

    @Override
    protected ItemDiarySubPictureBinding createViewBinding(LayoutInflater from, ViewGroup viewGroup) {
        return ItemDiarySubPictureBinding.inflate(from, viewGroup, false);
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void convertItem(ItemDiarySubPictureBinding binding, int position, String item) {
        updateImage(binding.imgUpload, item);
    }

    public void updateImage(ImageView img1, String images) {
        if (EmptyUtil.isEmpty(images)) {
            Glide.with(img1).load(R.drawable.icon_image_loss).into(img1);
        } else {
            Glide.with(img1).load(images).into(img1);
        }
    }
}
